package maximumTime;

public class Solution {
    public String maximumTime(String time) {
        //  x*10+y<24的最大值
        char[] h = time.substring(0,2).toCharArray();
        char[] m = time.substring(3,5).toCharArray();
        if(h[0] == '?') {
            if(h[1]!='?'){
                if(h[1]<'4'){
                    h[0] = '2';
                }else {
                    h[0] = '1';
                }
            } else {
                h[0] = '2';
            }
        }
        if(h[1] == '?') {
            if(h[0]<'2') {
                h[1] = '9';
            } else {
                h[1] = '3';
            }
        }

        if(m[0] == '?'){
            m[0] = '5';
        }
        if(m[1] == '?'){
            m[1] = '9';
        }
        return new String(h)+":"+new String(m);
    }
}
